package com.exam.mapper;

import com.exam.entity.PaperManage;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PaperMapper {
    @Select("select paperId, questionType,questionId from paper_manage")
    List<PaperManage> findAll();

    @Select("select paperId, questionType,questionId from paper_manage where paperId = #{paperId}")
    List<PaperManage> findById(Integer paperId);

    @Insert("insert into paper_manage(paperId,questionType,questionId) values " +
            "(#{paperId},#{questionType},#{questionId})")
    int add(PaperManage paperManage);

    @Select("select paperId from exam_manage where examCode = #{examCode}")
    int findPaperIdByExamCode(Integer examCode);

    //通过试卷编号查询考试时间
    @Select("select examDate from exam_manage where paperId = #{paperId}")
    String findExamTimeByPaperId(Integer paperId);

    //删除题目
    @Delete("delete from paper_manage where questionType = #{questionType} and questionId = #{questionId}")
    int deleteByQuestionAndType(@Param("questionType")Integer questionType, @Param("questionId")Integer questionId);
}
